package com.heima.wemedia.controller.v1;

import com.heima.common.dtos.AppHttpCodeEnum;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.admin.pojos.AdUser;
import com.heima.model.wemeida.dtos.WmSensitivPageReqeDto;
import com.heima.model.wemeida.pojos.WmSensitive;
import com.heima.wemedia.service.WmSensitiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/sensitive")
public class WmSensitiveController {

    @Autowired
    private WmSensitiveService wmSensitiveService;

    /**
     * 分页查询敏感词
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult<List<WmSensitive>> findList(@RequestBody WmSensitivPageReqeDto dto, AdUser adUser) {
        return wmSensitiveService.findList(dto);
    }

    /**
     * 新增敏感词
     */
    @PostMapping("/save")
    public ResponseResult saveMGC(@RequestBody WmSensitive wmSensitive) {
        wmSensitiveService.saveMGC(wmSensitive);
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }

    /**
     *删除敏感词
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult deleteMGC(@PathVariable Integer id){
       return wmSensitiveService.deleteMGC(id);
    }

    /**
     * 修改敏感词
     */
    @PostMapping("/update")
    public ResponseResult updateMGC(@RequestBody WmSensitive wmSensitive){
        wmSensitiveService.updateMGC(wmSensitive);
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }
}
